﻿using System;
using Avalonia.Controls.Notifications;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using NewUI.Views;
using SukiUI.Controls;
using SukiUI.Dialogs;
using SukiUI.Toasts;

namespace NewUI.ViewModels;

public partial class DialogsViewModel : ViewModelBase
{
    public InfoBarViewModel InfoBarViewModel { get; set; } = new();
    
    [RelayCommand]
    private void ShowInfoToast()
    {
        //SukiHost.ShowToast("A Simple Toast", "This is the content of an info toast.", NotificationType.Information);
 
        MainWindow.ToastManager.CreateSimpleInfoToast()
            .WithTitle("A Simple Toast")
            .WithContent("This is the content of an info toast.")
            .Queue();
    }
    
    [RelayCommand]
    private void ShowSuccessToast() => ShowTypeDemoToast(NotificationType.Success);
    
    
    [RelayCommand]
    private void ShowErrorToast() => ShowTypeDemoToast(NotificationType.Error);
    
    private void ShowTypeDemoToast(NotificationType toastType)
    {
        MainWindow.ToastManager.CreateToast()
            .WithTitle($"{toastType}!")
            .WithContent(
                $"This is the content of {toastType.ToString().ToLowerInvariant()} toast.")
            .OfType(toastType)
            .Dismiss().After(TimeSpan.FromSeconds(3))
            .Dismiss().ByClicking()
            .Queue();
    }
    
    [RelayCommand]
    private void OpenStandardDialog()
    {
        MainWindow.DialogManager.CreateDialog()
            .WithTitle("A Standard Dialog")
            .WithContent("This is a standard dialog. Click the button below to dismiss.")
            .WithActionButton("Dismiss", _ => { }, true)
            .TryShow();
    }
}

public partial class InfoBarViewModel : ViewModelBase
{
    [ObservableProperty]
    private int _iconSize = 12;

    [ObservableProperty]
    private bool _isTextSelectable;

    [ObservableProperty]
    private bool _isOpen = true;

    [ObservableProperty]
    private bool _isClosable = true;

    [ObservableProperty]
    private bool _isOpaque = false;

    [RelayCommand]
    private void RefreshIsOpenStatus()
    {
        IsOpen = true;
    }
}